// Author: Ivan Kazmenko (gassa@mail.ru)
// Generator for problem "clubs"
module gen;
import std.algorithm;
import std.conv;
import std.exception;
import std.format;
import std.random;
import std.range;
import std.stdio;

immutable string testFormat = "%03d";
enum generateAnswers = false;

immutable int minN =   2;
immutable int maxN = 100;

struct Test
{
	int n;

	string comment;

	void validate () const
	{
		enforce (minN <= n && n <= maxN);
		enforce (n % 2 == 0);
	}

	void print (File f) const
	{
		f.writeln (n);
	}

	string log () const
	{
		return format ("%s (n = %s)", comment, n);
	}
}

Test [] tests;

void printAllTests ()
{
	foreach (testNumber, test; tests)
	{
		test.validate ();
		auto testString = format (testFormat, testNumber + 1);
		auto f = File (testString, "wt");
		test.print (f);
		static if (generateAnswers)
		{
			auto g = File (testString ~ ".a", "wt");
			test.printAnswer (g);
		}
		writeln (testString, ": ", test.log ());
	}
}

Mt19937 rndLocal;

void main ()
{
	rndLocal.seed (157_159_001);

	tests ~= Test (  4, "example test 1");
	tests ~= Test (  6, "example test 2");

	tests ~= Test (  2, "small test 1");
	tests ~= Test (  8, "small test 2");
	tests ~= Test ( 10, "small test 3");

	tests ~= Test ( 26, "medium test 1");
	tests ~= Test ( 38, "medium test 2");
	tests ~= Test ( 58, "medium test 3");

	tests ~= Test ( 80, "large test 1");
	tests ~= Test ( 92, "large test 2");
	tests ~= Test ( 98, "large test 3");
	tests ~= Test (100, "large test 4");

	printAllTests ();
}
